java program to count the spaces